<run> tags.
Endpoint
Path Parameters
string
required
Unique identifier for the conversation room. Used to maintain isolated conversation state and sandbox environments.
Request Body
string
required
The user’s message text. Must be at least 1 character long.
string
Optional identifier for the user sending the message. Used to track message authorship in multi-user scenarios.
Response
string
The AI assistant’s response text. May include command outputs if the assistant executed sandbox commands.
DuetMessage[]
The complete conversation history for this room (last 50 messages). Each message includes:
AI Behavior
The assistant uses the@cf/meta/llama-3-8b-instruct model with the following system prompt:
“You are Duet, a concise pair-programming assistant. You can run commands in a sandbox usingThe assistant automatically executes commands wrapped in<run>command</run>tags. When asked to perform an action, briefly explain what you will do and wrap the exact shell command(s) in<run>tags. Do NOT include predicted output in your response - just provide the explanation and command.”
<run> tags and appends output to the response.
Example Request
Example Response
Error Responses
400 Bad Request
Returned when request validation fails:404 Not Found
Returned when the room ID is missing from the URL path.405 Method Not Allowed
Returned when using a method other than POST.Implementation Details
- Conversation history is limited to the last 10 messages when calling the AI model (cf-worker/index.ts:164)
- Total message history stored per room: 50 messages (cf-worker/index.ts:179)
- Command output is truncated to 500 characters (cf-worker/index.ts:200)
- Sandbox instances are isolated per room using naming pattern:
sandbox-{roomID}(cf-worker/index.ts:196)
Related Endpoints
- POST /api/rooms//sandbox/exec - Execute commands directly without AI
- DELETE /api/rooms/ - Clean up room resources